package com.yc.demo.controller;

import com.yc.demo.common.ResponseEntity;
import com.yc.demo.entity.SysUser;
import com.yc.demo.enums.ResponseEnum;
import com.yc.demo.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by yc on 2019/4/4.
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private ISysUserService sysUserService;
    @PostMapping("/login")
    public ResponseEntity<SysUser> login(@RequestBody SysUser user){
        SysUser sysUser=sysUserService.login(user);
        if (sysUser==null){
            return new ResponseEntity(ResponseEnum.LOGIN_NOT_USER);
        }

        return new ResponseEntity("登录成功");
    }

}
